<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
</head>
<body>
    <h1>小黑的书架</h1>
    <div id="app">
     <ul>
        <li  v-for="(item,index) in list" >{{item}} <button @Click="fu(index)">删除</button></li>
     </ul>
     <hr>
     <ul>
        <li v-for="(item,index) in booksList" :key="item.id">
            <span>{{item.name}}</span>
            <span>{{item.author}}</span>
            <button @click=del(item.id)>删除</button>
        </li>
     </ul>
    </div>
</body>
<script>
   const app=new Vue({
    el:'#app',
    data:{
     list:["《红楼梦》 曹雪芹","《西游记》吴承恩","《水浒传》施耐庵","《三国演义》 罗贯中"],
     booksList: [
          { id: 1, name: '《红楼梦》', author: '曹雪芹' },
          { id: 2, name: '《西游记》', author: '吴承恩' },
          { id: 3, name: '《水浒传》', author: '施耐庵' },
          { id: 4, name: '《三国演义》', author: '罗贯中' }
        ]
    },
    methods: {
        fu(i){
            this.list.splice(i,1)
        },
        del(i){
         this.booksList=this.booksList.filter(item=>item.id!==i)
        }
    }
   })
</script>
</html>